package cn.net.lwj.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

    public static final SimpleDateFormat FULL_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static final SimpleDateFormat SHORT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public static String fullFormat(Date date) {
        return date == null ? "" : FULL_FORMAT.format(date);
    }

    public static String shortFormat(Date date) {
        return date == null ? "" : SHORT_FORMAT.format(date);
    }

    public static String xgformat(Date date) {
        return date == null ? "" : new SimpleDateFormat("yyyy/MM/dd").format(date);
    }

    /**
     * 生成一串日期数字
     * @param date
     * @return 20201116165828
     */
    public static String fullNumformat(Date date) {
        return date == null ? "" : new SimpleDateFormat("yyyyMMddHHmmss").format(date);
    }
    public static String shortNumformat(Date date) {
        return date == null ? "" : new SimpleDateFormat("yyyyMMdd").format(date);
    }

    public static String format(Date date, String fmt) {
        return date == null ? "" : new SimpleDateFormat(fmt).format(date);
    }

}
